<?xml version="1.0" encoding="UTF-8"?>
<!--
  Created by IntelliJ IDEA.
  User: imon
  Date: 2/18/13
  Time: 9:06 PM
-->

<ui:composition template="/templates/layout.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:ui="http://java.sun.com/jsf/facelets">

    <ui:define name="#{var['layout.title']}">
        <title>#{msg['home.title']}</title>
    </ui:define>


    <ui:define name="#{var['layout.content']}">

        <ui:include src="templates/user_menu.xhtml"/>

        <h:form id="form">
            <div>
                <div class="homeContainerLeft">
                    <c:choose>
                        <c:when test="${not empty homeController.recentIssues}">
                            <p:panel id="panel">
                                <p:dataList id="recentIssueDataList" value="#{homeController.recentIssues}"
                                            var="issueList"
                                            paginator="true" rows="4" effectSpeed="fast"
                                            paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}"
                                            rowsPerPageTemplate="4,10,15" type="none">

                                    <f:facet name="header">
                                        #{msg['home.facet']}
                                    </f:facet>

                                    <div style="padding-left: 10px">

                                        <h:link target="_blank" style="color: #6495ed; font-size: 20px"
                                                value="#{issueList.title}"
                                                outcome="donate.xhtml">
                                            <f:param name="issue" value="#{issueList.issueId}"/>
                                            <f:param name="user" value="#{loginController.user.userId}"/>
                                        </h:link>


                                        <h:panelGrid columns="2">
                                            <h:outputLabel value="#{msg['home.helpFor']} "/>
                                            <h:outputText value="#{issueList.helpFor}"/>
                                            <h:outputLabel value="#{msg['home.description']} "/>
                                            <h:outputText escape="false" value="#{issueList.description}"/>
                                            <h:outputLabel value="#{msg['home.creationDate']} "/>
                                            <h:outputText value="#{issueList.createdDate}"/>
                                            <h:outputLabel value="#{msg['home.collectedAmount']} "/>
                                            <h:outputText value="#{issueList.collectedAmount}"/>
                                            <h:outputLabel value="#{msg['home.requiredAmount']} "/>
                                            <h:outputText value="#{issueList.requiredAmount}"/>
                                            <p:spacer/>

                                        </h:panelGrid>

                                    </div>
                                    <p:separator/>
                                </p:dataList>
                            </p:panel>
                        </c:when>
                        <c:otherwise>
                            <p:panel>
                                <f:facet name="header">
                                    #{msg['home.facet']}
                                </f:facet>
                                <p:outputLabel>
                                    #{msg['home.noIssueFound']}
                                </p:outputLabel>
                            </p:panel>
                        </c:otherwise>
                    </c:choose>
                </div>

                <div class="homeContainerRight">
                    <p:panel>
                        <f:facet name="header">
                            #{msg['home.searchFacet']}
                        </f:facet>

                        <h:panelGrid columns="2">
                            <p:outputLabel value="#{msg['home.search']}"/>
                            <p:inputText size="36" id="searchText" value="#{homeController.searchText}"/>
                            <p:watermark value="${msg['home.search.waterMark']}" for="searchText"/>
                            <p:commandButton value="#{msg['home.search.button']}" update="panel"
                                             actionListener="#{homeController.searchIssue}"/>
                        </h:panelGrid>

                    </p:panel>
                </div>
            </div>
        </h:form>
    </ui:define>


</ui:composition>
